#!/bin/gawk -f
#
# Convert Aqua restraint file to DIANA format
#

BEGIN {
    if ( !force ) force = 1.0
    if ( !expon ) expon = 2
}

NR < 3 {
    print "#", $0
    next
}

/^#/ {
    print
    next
}

$1 == "ANGLE" {
    up = $5
    lo = $6
#    printf( "%4i %-5s %-5s%8.1f%8.1f%9.2e\n", $3, $2, $4, lo, up, force )
    printf( "%4i %-5s %-5s%8.1f%8.1f\n", $3, $2, $4, lo, up )
    next
}

$1 ~ /UPP$/ || $1 ~ /UPLO$/ {
#    printf( "%3i %-5s%-5s%4i %-5s%-5s%7.2f  %8.2e\n", $3, $2, $4, $6, $5, $7, $8, force )
    printf( "%3i %-5s%-5s%4i %-5s%-5s%7.2f\n", $3, $2, $4, $6, $5, $7, $8 )
    next
}

    {
    print "NOT CONVERTED:", $0
}
